﻿<?php
	defined('_JEXEC') or die('Restricted access');
	$url = $this->baseurl.'/images/com_retailshop/';	
?>

<?	
	$task = $_GET["task"];
?>
<div class="wrapper wmain">
<div id="content">
    <div id="nav">
		<h2>SlideShow</h2>
        <ul>
			<li><a href="#product-add-general">Slideshow General</a></li>
        </ul>
	</div>
	<div id="manager">	
<form id="adminForm" name="adminForm" action="index.php?option=com_retailshop" method="post" enctype="multipart/form-data">	
<div id="new-slideshow">
	<p>Slideshow 
		<? if($task != 'editslideshow') { ?><button type="submit" id="btnaddnew">Add New Slider</button> <? } ?>
				 <button type="submit" id="btnsavealll">Save All Change</button>
	</p>			
</div>
<div id="slideimagess">
	<div class="slide" id="slide1">
		<h3>Slideshow <span>&or;</span></h3>
			<div style="display: none;" class="togglebox" >
            <div class="content">
                            <div class="element">
                  				<label>Title</label>
								<input type="text" name="slidetitle[]" value="<?php echo $task=='editslideshow'? $this->slide->title :''; ?>" />
              				</div>
                			<div class="element">
								<label>Content</label>
								<textarea name="slidecontent[]"><?php echo $task=='editslideshow'? $this->slide->content :''; ?></textarea>
							</div>
							<div class="element">
								<label>Link</label>
								<input type="text" name="slidelink[]" value="<?php echo $task=='editslideshow'? $this->slide->link :''; ?>" />
							</div>
							<div class="element">
								<label>Image</label>
								<input type="file" name="slideimage[]" value="" />
								<?php if($task=='editslideshow') { ?><image src="<?php echo $url.''.$this->slide->image_url; ?>" width="100px" height="100px" /> <? } ?>
							</div>
							
							<div class="button-toggle">
								<a href="#" class="remove" >Remove</a>
								<a href="#" class="cancel">Cancel</a>
							</div>							
			</div>
		</div>
	</div>			
</div>
	<input type="hidden" name="view" value="myshop" />
	<input type="hidden" name="task" value="saveslide" />	
	<input type="hidden" name="action" value="<?php echo $task=='editslideshow' ? 'edit' : 'addnew'?>" />
	<?php echo $task=='editslideshow' ? '<input type="hidden" name="slideid" value="'.$this->slide->id.'" />' : ''?>
</form>
</div>
<script>
	var leaght = 10;
	$("#btnaddnew").click(function(){		
		leaght += 1;
		var content = '<div class="slide" id="lengthSlider_'+leaght+'"><h3>Slideshow <span>&or;</span></h3><div style="display: none;" class="togglebox"><div class="content"><div class="element"><label>Title</label><input type="text" name="slidetitle[]" value="" /></div><div class="element"><label>Content</label><textarea name="slidecontent[]"></textarea></div><div class="element"><label>Link</label><input type="text" name="slidelink[]" value="" /></div><div class="element"><label>Image</label><input type="file" name="slideimage[]" value="" /></div><div class="button-toggle"><a href="#" class="remove" class="btn-lengthSlider" id="slide_'+leaght+'">Remove</a><a href="#" class="cancel">Cancel</a></div></div></div></div>';	
		$('#slideimagess').after(content);
		
		return false;
	});
	
	$('a[id^="slide_"]').live('click',function(){		
		var arr = $(this).attr('id').split('_');		
		$('#lengthSlider_'+arr[1]).remove();
		return false;
	});
	$('#toolbar-new-slide').click(function() {		
		//$('#adminForm').submit();		
		return false;
	});
</script>